<template>
  <div class="ellipsis-container">
    <Tooltip placement="top" v-if="tooltip">
      <div slot="content" class="text-wrap">{{ content }}</div>
      <div :class="{'ellipsis-sentence': type === 'sentence', 'ellipsis-paragraph': type === 'paragraph'}"
           v-bind:style="{width: textwidth, '-webkit-line-clamp':textline}">
        {{ content }}
      </div>
    </Tooltip>
    <div v-else :class="{'ellipsis-sentence': type === 'sentence', 'ellipsis-paragraph': type === 'paragraph'}"
         v-bind:style="{width: textwidth, '-webkit-line-clamp':textline}">
      {{ content }}
    </div>
  </div>
</template>

<script>
export default {
  name: 'Ellipsis',
  props: {
    type: {
      type: String
    },
    content: {
      type: String
    },
    tooltip: {
      type: Boolean
    },
    textwidth: {
      type: String
    },
    textline: {
      type: Number
    }
  }
}

</script>
<style>
  .ellipsis-sentence {
    white-space:nowrap;
    overflow:hidden;
    text-overflow:ellipsis;
  }
  .ellipsis-paragraph {
    overflow : hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-box-orient: vertical;
  }
.text-wrap {
  white-space: normal;
}
</style>
